/**
 * @(#)LoginUtils.java, 2018/2/6.
 * <p/>
 * Copyright 2018 Kerr Wang, Inc. All rights reserved.
 * KERRWANG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package org.wangzx.exercise.utils;

import org.wangzx.exercise.enums.LoginType;
import org.wangzx.exercise.meta.vo.UserVO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author hzwangzuxiang(ahscwzx@163.com)
 */
public class LoginUtils {

    static public UserVO loginCheck(HttpServletRequest request) {
        UserVO userVO = new UserVO();
        HttpSession session = request.getSession(false);

        if(session == null) {
            userVO.setLoginType(LoginType.UN_LOGIN.getValue());
        } else {
            userVO.setLoginType((Integer)session.getAttribute("userType"));
            userVO.setUserName((String)session.getAttribute("userName"));
        }
        return userVO;
    }
}